﻿using GPS.COMMON;
using GPS.Controllers.GPS_NghiepVu;
using GPS.DataAccessLayer;
using GPS.ENTITYS;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace GPS.GPS_DAL
{
    public class GPS_DanhMucDAO
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public void GPS_DANHMUC_DVHC_DELETE()
        {
            
            OracleHelper.ExecuteNonQuery(GPS_OracleConnectHelper.ConnectionString, CommandType.StoredProcedure
                                                                , "GPS_DANHMUC.GPS_DANHMUC_DVHC_DELETE"
                                                                );

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public void GPS_DANHMUC_DVHC_INSERT(CrudModelSDONVIHC1 model)
        {
            var _pDVHC_ACTIVE = (model.TrangThai== null || model.TrangThai == false) ? "0" : "1";
            var pDVHC_MA = new OracleParameter("pDVHC_MA", OracleDbType.Varchar2, (model.MaDvhc == null ? DBNull.Value : (object)model.MaDvhc), ParameterDirection.Input);
            var pDVHC_MAQL = new OracleParameter("pDVHC_MAQL", OracleDbType.Varchar2, (model.MaDVQL == null ? DBNull.Value : (object)model.MaDVQL), ParameterDirection.Input);
            var pDVHC_MADV = new OracleParameter("pDVHC_MADV", OracleDbType.Decimal, (model.MaDV == null ? DBNull.Value : (object)model.MaDV), ParameterDirection.Input);
            var pDVHC_TEN = new OracleParameter("pDVHC_TEN", OracleDbType.Varchar2, (model.TenDvhc == null ? DBNull.Value : (object)model.TenDvhc), ParameterDirection.Input);
            var pDVHC_TENVT = new OracleParameter("pDVHC_TENVT", OracleDbType.Varchar2, (model.TenNganGon == null ? DBNull.Value : (object)model.TenNganGon), ParameterDirection.Input);
            var pDVHC_TENDAYDU = new OracleParameter("pDVHC_TENDAYDU", OracleDbType.Varchar2, (model.TenDayDu == null ? DBNull.Value : (object)model.TenDayDu), ParameterDirection.Input);
            var pDVHC_LOAI = new OracleParameter("pDVHC_LOAI", OracleDbType.Varchar2, (model.LoaiDvhc == null ? DBNull.Value : (object)model.LoaiDvhc), ParameterDirection.Input);
            var pDVHC_MOTA = new OracleParameter("pDVHC_MOTA", OracleDbType.Varchar2, (model.GhiChu == null ? DBNull.Value : (object)model.GhiChu), ParameterDirection.Input);
            var pDVHC_NGAYNHAP = new OracleParameter("pDVHC_NGAYNHAP", OracleDbType.Date, (model.NgayTao == null ? DBNull.Value : (object)model.NgayTao), ParameterDirection.Input);
            var pDVHC_NGUOINHAP = new OracleParameter("pDVHC_NGUOINHAP", OracleDbType.Varchar2, (model.NguoiTao == null ? DBNull.Value : (object)model.NguoiTao), ParameterDirection.Input);
            var pDVHC_NGAYSUA = new OracleParameter("pDVHC_NGAYSUA", OracleDbType.Date, (model.NgaySua == null ? DBNull.Value : (object)model.NgaySua), ParameterDirection.Input);
            var pDVHC_NGUOISUA = new OracleParameter("pDVHC_NGUOISUA", OracleDbType.Varchar2, (model.NguoiSua == null ? DBNull.Value : (object)model.NguoiSua), ParameterDirection.Input);
            var pDVHC_ACTIVE = new OracleParameter("pDVHC_ACTIVE", OracleDbType.Varchar2, (_pDVHC_ACTIVE == null ? DBNull.Value : (object)_pDVHC_ACTIVE), ParameterDirection.Input);
           
            OracleHelper.ExecuteNonQuery(GPS_OracleConnectHelper.ConnectionString, CommandType.StoredProcedure
                                                                , "GPS_DANHMUC.GPS_DANHMUC_DVHC_INSERT"
                                                                , pDVHC_MA
                                                                , pDVHC_MAQL
                                                                , pDVHC_MADV
                                                                , pDVHC_TEN
                                                                , pDVHC_TENVT
                                                                , pDVHC_TENDAYDU
                                                                , pDVHC_LOAI
                                                                , pDVHC_MOTA
                                                                , pDVHC_NGAYNHAP
                                                                , pDVHC_NGUOINHAP
                                                                , pDVHC_NGAYSUA
                                                                , pDVHC_NGUOISUA
                                                                , pDVHC_ACTIVE
                                                                );

        }

        //GPS_KH_LH_1_TH_UPDATE
        public void GPS_DANHMUC_SLLDT_UPDATE(CrudModelSLLDT model)
        {
            var pLLDT_DVGTVT_MA = new OracleParameter("pKH_LH_DVGTVT_MA", OracleDbType.Varchar2, (model.LLDT_DVGTVT_MA == null ? DBNull.Value : (object)model.LLDT_DVGTVT_MA), ParameterDirection.Input);
            var pLLDT_HGPLX_MA = new OracleParameter("pKH_LH_KH_MA", OracleDbType.Varchar2, (model.LLDT_HGPLX_MA == null ? DBNull.Value : (object)model.LLDT_HGPLX_MA), ParameterDirection.Input);
            var pLLDT_LUULUONG = new OracleParameter("pKH_LH_GV_MA", OracleDbType.Decimal, (model.LLDT_LUULUONG == null ? DBNull.Value : (object)model.LLDT_LUULUONG), ParameterDirection.Input);
            var pLLDT_MOTA = new OracleParameter("pKH_LH_MONHOC_MA", OracleDbType.Varchar2, (model.LLDT_MOTA == null ? DBNull.Value : (object)model.LLDT_MOTA), ParameterDirection.Input);
            var pLLDT_ACTIVE = new OracleParameter("pKH_LH_HTDT_MA", OracleDbType.Varchar2, (model.LLDT_ACTIVE == null ? DBNull.Value : (object)model.LLDT_ACTIVE), ParameterDirection.Input);
            var pID = new OracleParameter("pID", OracleDbType.Varchar2, (model.ID == null ? DBNull.Value : (object)model.ID), ParameterDirection.Input);
            var pNGUOI_SUA = new OracleParameter("pNGUOI_SUA", OracleDbType.Varchar2, (model.LLDT_NGUOISUA == null ? DBNull.Value : (object)model.LLDT_NGUOISUA), ParameterDirection.Input);
            //string connectionString = System.Configuration.ConfigurationManager.AppSettings["OracleConnectionString"];
            OracleHelper.ExecuteNonQuery(GPS_OracleConnectHelper.ConnectionString, CommandType.StoredProcedure
                                                                , "GPS_DANHMUC.GPS_DANHMUC_SLLDT_UPDATE"
                                                                , pLLDT_DVGTVT_MA
                                                                , pLLDT_HGPLX_MA
                                                                , pLLDT_LUULUONG
                                                                , pLLDT_MOTA
                                                                , pLLDT_ACTIVE
                                                                , pID
                                                                , pNGUOI_SUA
                                                                );

        }

    }
}